<?php

namespace plugin\admin\app\controller\plan;


use plugin\admin\app\logic\plan\PartLogic;
use support\Request;
use support\Response;
use plugin\admin\app\controller\AuthController;
use support\exception\BusinessException;

class PartController extends AuthController
{
    
    /**
     * 浏览
     * @return Response
     */
    public function index(): Response
    {
        return view('plan/part/index');
    }

    /**
     * 查询
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function select(Request $request): Response
    {
        return PartLogic::getInstance()->select($request);
    }


    /**
     * 更新
     * @param Request $request
     * @return Response
     * @throws BusinessException
    */
    public function update(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return PartLogic::getInstance()->update($request);
        }

        return view('plan/part/update');
    }

    /**
     * 删除
     * @param Request $request
     * @return Response
     * @throws \support\exception\BusinessException
     */
    public function delete(Request $request): Response
    {
        return PartLogic::getInstance()->delete($request);
    }

    /**
     * AI生成段落
     * @param Request $request
     * @return Response
     * @throws \plugin\admin\app\exception\AdminException
     */
    public function generated(Request $request): Response
    {
        return PartLogic::getInstance()->generated($request);
    }

    /**
     * 获取AI生成进度
     * @param Request $request
     * @return Response
     * @throws \plugin\admin\app\exception\AdminException
     */
    public function getProgress(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return PartLogic::getInstance()->getProgress($request);
        }
        return view('plan/part/Progress');
    }

//    /**
//     * 重改描述词
//     * @param Request $request
//     * @return Response
//     * @throws \plugin\admin\app\exception\AdminException
//     */
//    public function generatedPrompt(Request $request): Response
//    {
//        return PartLogic::getInstance()->generatedPrompt($request);
//    }
//
//    /**
//     * 重改AI图
//     * @param Request $request
//     * @return Response
//     * @throws \plugin\admin\app\exception\AdminException
//     */
//    public function generatedImage(Request $request): Response
//    {
//        if ($request->method() === 'POST') {
//            return PartLogic::getInstance()->generatedImage($request);
//        }
//        return view('plan/part/image');
//
//    }

    /**
     * 字幕管理
     * @param Request $request
     * @return Response
     * @throws \plugin\admin\app\exception\AdminException
     */
    public function subTitle(Request $request): Response
    {
        return view('plan/part/subtitle');

    }

    /**
     * 重新生成
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function aiRegenerate(Request $request): Response
    {
        return PartLogic::getInstance()->aiRegenerate($request);
    }

    /**
     * AI会话
     * @param Request $request
     * @return Response
     * @throws \app\exception\IndexException
     */
    public function aisession(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return PartLogic::getInstance()->aisession($request);
        }
        return view('plan/part/aisession');

    }

    /**
     * 导出excel
     * @param Request $request
     * @return Response
     * @throws \app\exception\IndexException
     */
    public function download(Request $request): Response
    {
        return PartLogic::getInstance()->download($request);
    }

    /**
     * 导入excel
     * @param Request $request
     * @return Response
     * @throws \plugin\admin\app\exception\AdminException
     */
    public function batchUpload(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return PartLogic::getInstance()->batchUpload($request);
        }
        return view('plan/part/upload');
    }

    /**
     * 上传参考图
     * @param Request $request
     * @return Response
     * @throws \plugin\admin\app\exception\AdminException
     */
//    public function uploadImage(Request $request): Response
//    {
//        if ($request->method() === 'POST') {
//            return PartLogic::getInstance()->uploadImage($request);
//        }
//        return view('plan/part/uploadimage');
//    }

    /**
     * 图生图
     * @param Request $request
     * @return Response
     * @throws \plugin\admin\app\exception\AdminException
     */
    public function generatedImageToImage(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return PartLogic::getInstance()->generatedImageToImage($request);
        }
        return view('plan/part/uploadimage');
    }

}
